<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--通用查询-->
      <queryHeader :dict="dict" :permission="permission" />
      <!--通用编辑-->
      <crudOperation :permission="permission" />
    </div>

    <!--表格渲染-->
    <el-table ref="table" v-loading="crud.loading" :data="crud.data" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
      <!--多选框-->
      <el-table-column type="selection" width="55" />
      <!--展示字段-->
      <el-table-column v-if="columns.visible('hospitalName')" prop="hospitalName" label="医院名称" :width="180" />
      <el-table-column v-if="columns.visible('hospitalLogo')" prop="hospitalLogo" label="医院Logo" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('hospitalContactPhone')" prop="hospitalContactPhone" label="联系电话" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('hospitalAddress')" prop="hospitalAddress" label="医院地址" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('isPrice')" prop="isPrice" label="是否定价" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          {{ dict.label.status_common_yesno[scope.row.isPrice] }}
        </template>
      </el-table-column>
      <el-table-column v-if="columns.visible('countDevice')" prop="countDevice" label="设备数量" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('countOrder')" prop="countOrder" label="开单数量" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('amountTotal')" prop="amountTotal" label="总订单金额" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('amountPay')" prop="amountPay" label="总支付金额" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('amountPayFree')" prop="amountPayFree" label="免单金额" :show-overflow-tooltip="true" />

      <!--操作-->
      <el-table-column label="操作" width="310px" align="center" fixed="right">
        <template slot-scope="scope">
          <!--通用编辑删除-->
          <udOperation :data="scope.row" :permission="permission">
            <template slot="left">
              <el-button size="mini" type="text">
                <router-link :to="'/hospital/building/' + scope.row.hospitalId">楼宇</router-link>
              </el-button>
              <el-button size="mini" type="text">
                <router-link :to="'/hospital/depart/' + scope.row.hospitalId">科室</router-link>
              </el-button>
              <el-button size="mini" type="text">
                <router-link :to="'/hospital/price/' + scope.row.hospitalId">定价</router-link>
              </el-button>
              <el-button size="mini" type="text">
                <router-link :to="'/hospital/rule/' + scope.row.hospitalId">租赁规则</router-link>
              </el-button>
            </template>
          </udOperation>
        </template>
      </el-table-column>
    </el-table>

    <!--分页组件-->
    <pagination />

    <!--表单渲染-->
    <editForm />
  </div>
</template>

<script>
import crudTHospital from '@/api/business/bed/hospital'
import queryHeader from './module/queryHeader'
import editForm from './module/editForm'
import CRUD, { presenter } from '@crud/crud'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'
import udOperation from '@crud/UD.operation'

// crud交由presenter持有
const crud = CRUD({ title: 'Hospital', url: 'hospital/list/page/token', crudMethod: { ...crudTHospital }, pkIdName: 'hospitalId' })

export default {
  name: 'THospital',
  components: { queryHeader, editForm, crudOperation, pagination, udOperation },
  dicts: ['status_common_yesno'],
  mixins: [presenter(crud)],
  data() {
    return {
      // 对应几个按钮操作
      permission: {
        add: [],
        edit: [],
        del: []
      }
    }
  },
  methods: {

  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  /deep/ .el-input-number .el-input__inner {
    text-align: left;
  }
</style>
